﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using RuleCode.Table;
using System.Xml.Linq;

namespace chatblog
{
    public partial class selectarea : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser.dealcookie();
                BindTree();
            }
        }
        private void BindTree()
        {
            string sql = " select 省编码 from 省 ";
            DataTable dt = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
            TreeNode childNode;
            
            TreeView1.Nodes.Clear();
            foreach (DataRow item in dt.Rows)
            {
                childNode = new TreeNode();
                childNode.Value = item[0].ToString();
                childNode.Text = item[0].ToString();
                this.TreeView1.Nodes.Add(childNode);
            }

            TreeView1.ExpandAll();
        }

        protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
        {
            if (Request["id"] != null && this.TreeView1.SelectedNode != null)
            {
                cbuser.setarea(this.TreeView1.SelectedNode.Value); 
                ScriptManager.RegisterStartupScript(this.TreeView1, this.TreeView1.GetType(), "hasSelected",
                        "<script type =\"text/javascript\" >treeViewSelectChanged('" + Request["id"]
                        + "','" + this.TreeView1.SelectedNode.Value + "');</script>", false);
            }
        }
    }
}
